﻿HmJS.$Import('crypt.array.cryptographysha512');
HmJS.$Import('crypt.array.cryptographyhex');
HmJS.$Import('crypt.string.cryptographyutf8');
HmJS.$Import('crypt.string.cryptographycommon');

/*
---
name: String.SHA-512
version: 0.3-1
description: String SHA512 hashing.
license: MIT-style
download: http://mootools.net/forge/p/string_cryptography
source: http://github.com/sixtyseconds/mootools-string-cryptography
authors: [Christopher Pitt, Enrique Erne]
requires:
- Core/String
- String.toUTF8
- String.toBin
- Array.toSHA512
- Array.toHex
provides: [String.toSHA512]
...
*/

HmJS.register('crypt.string.cryptographysha512', function ($ns) {

	var sha512 = function (string, size, hexUpperCase) {
		var bin = string.toUTF8().toBin(size),
				proc = bin.toSHA512(string.length * size);

		return proc.toHex(hexUpperCase);
	};

	String.implement({
		'toSHA512': function () {
			return sha512(this, 8, 0);
		}
	});

});
